package com.hxkj.client.service;

import com.hxkj.domain.po.LoginToken;
import com.hxkj.domain.po.SysUser;
import com.hxkj.domain.result.UserParameterDataStruct;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * created by kezhijie on 2018/8/28 10:00.
 * email to kezhijie@hxoss.com
 */
@FeignClient(name = "cms-user-center")
public interface UserCenterServiceClient extends BaseClient {

    /**
     * 测试用户连通性
     * @return
     */
    @RequestMapping(value = "/user/entry", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    String userEntry();

    /**
     * 用户登录
     * @param sysUser
     * @return
     */
    @RequestMapping(value = "/user/login", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultDataStruct<LoginToken> userLogin(@RequestBody SysUser sysUser);

    /**
     * 邮箱注册
     * @param userParameterDataStruct
     */
    @RequestMapping(value = "/user/registerByEmail", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct userRegisterByEmail(@RequestBody UserParameterDataStruct<SysUser, String> userParameterDataStruct);

    /**
     * 手机号注册
     * 此接口调用之前，需要先调用动态码接口
     * @param userParameterDataStruct
     */
    @RequestMapping(value = "/user/registerByPhone", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultDataStruct<LoginToken> userRegisterByPhone(@RequestBody UserParameterDataStruct<SysUser, String> userParameterDataStruct) throws Exception;

    /**
     * 动态码登录
     * 此接口调用之前，需要先调用动态码接口
     * @param userParameterDataStruct
     */
    @RequestMapping(value = "/user/dynamicLogin", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultDataStruct<LoginToken> userDynamicLogin(@RequestBody UserParameterDataStruct<SysUser, String> userParameterDataStruct);

    /**
     * 如果没有oldPassword就是忘记密码
     * 如果有oldPassword就是修改密码
     * @param userParameterDataStruct
     * @throws Exception
     */
    @RequestMapping(value = "/user/updatePassword", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct userUpdatePassword(@RequestBody UserParameterDataStruct<SysUser, String> userParameterDataStruct);
    /**
     * 退出
     */
    @RequestMapping(value = "/user/logout", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct logout(@RequestParam("token") String token) throws Exception;

    @RequestMapping(value = "/user/logoutBySite", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct logoutBySite(@RequestBody String token) throws Exception;

    /**
     * 激活邮箱注册用户
     * @param sysUser
     */
    @RequestMapping(value = "/user/active", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct active(@RequestBody SysUser sysUser);

    /**
     *
     * @param sysUser
     * @return
     */
    @RequestMapping(value = "/user/exists", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultDataStruct<SysUser> exists(@RequestBody SysUser sysUser);

    /**
     * 发送激活邮件
     * @param userParameterDataStruct
     * @return
     */
    @RequestMapping(value = "/user/sendActiveEmail", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    ResultMessageStruct sendActiveEmail(@RequestBody UserParameterDataStruct<SysUser, String> userParameterDataStruct);
}
